# _*_ codeing : utf-8 _*_
# @Time : 2024-10-22
# @Author : wxp
# @File : fibonacci
# @Project : wxp-python

def fibonacci(n):
    """
    生成前 n 个斐波那契数列。
    :param n: 要生成的斐波那契数列的长度
    :return: 包含前 n 个斐波那契数的列表
    """
    if n <= 0:
        return []
    elif n == 1:
        return [0]
    elif n == 2:
        return [0, 1]

    fib_sequence = [0, 1]
    for i in range(2, n):
        next_value = fib_sequence[-1] + fib_sequence[-2]
        fib_sequence.append(next_value)

    return fib_sequence

    # 示例用法

if __name__ == '__main__':
    n = 10
    print(f"前 {n} 个斐波那契数列是: {fibonacci(n)}")